package sedev.shopping.business;

import sedev.shopping.data.LoaiNhomDAO;
import sedev.shopping.entities.LoaiNhom;
import sedev.shopping.entities.ListLoaiNhom;

public class LoaiNhomService {
	
	public static boolean addData(LoaiNhom data){
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.addData(data);
	}
	
	public static boolean updateData(LoaiNhom data){
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.updateData(data);
	}
	
	public static boolean removeData(long id){
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.removeData(id);
	}
	
	public static LoaiNhom getData(long id){
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.getData(id);		
	}
	
	public static ListLoaiNhom getListDataByProductType(long loai_san_pham_id){
		StringBuilder field = new StringBuilder();
		field.append(LoaiNhom.Properties.id.name());
		field.append(",").append(LoaiNhom.Properties.nhom_san_pham_id.name());
	
		StringBuilder condition = new StringBuilder();
		condition.append("1 AND 1");
		
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.getListData(field.toString(), condition.toString(), "", 0, 0, Long.valueOf(0));
	}
	
	public static ListLoaiNhom getListDataByProductGroup(long nhom_san_pham_id){
		StringBuilder field = new StringBuilder();
		field.append(LoaiNhom.Properties.id.name());
		field.append(",").append(LoaiNhom.Properties.loai_san_pham_id.name());
	
		StringBuilder condition = new StringBuilder();
		condition.append("1 AND 1");
		
		LoaiNhomDAO dao = new LoaiNhomDAO();
		return dao.getListData(field.toString(), condition.toString(), "", 0, 0, Long.valueOf(0));
	}
}
